package com.lottery.ruok.lottrey.chat.event.manager;

import com.lottery.ruok.lottrey.chat.event.listener.ChatEventConversationClickListener;
import com.lottery.ruok.lottrey.chat.event.listener.ChatEventConversationListBehaviorListener;
import com.lottery.ruok.lottrey.chat.event.listener.OnReceiveMessageListener;
import com.lottery.ruok.lottrey.chat.event.listener.OnSendMessageListener;

import io.rong.imkit.RongIM;

public class ConversationEventManager {

    public static void init() {
        setConversationClickListener(ChatEventConversationClickListener.getIntance());
        setConversationListBehaviorListener(ChatEventConversationListBehaviorListener.getInstance());
        setSendMessageListener(OnSendMessageListener.getInstance());
        setOnReceiveMessageListener(OnReceiveMessageListener.getInstance());
    }

    /**
     * 接收消息监听
     *
     * @param instance
     */
    private static void setOnReceiveMessageListener(OnReceiveMessageListener instance) {
        RongIM.getInstance().setOnReceiveMessageListener(instance);

    }

    /**
     * 发送消息监听
     *
     * @param instance
     */
    private static void setSendMessageListener(OnSendMessageListener instance) {
        RongIM.getInstance().setSendMessageListener(instance);
    }

    /**
     * 设置聊天操作
     *
     * @param chatEventConversationClickListener
     */
    public static void setConversationClickListener(ChatEventConversationClickListener chatEventConversationClickListener) {
        RongIM.getInstance().setConversationClickListener(chatEventConversationClickListener);
    }

    /**
     * 聊天记录列表操作
     *
     * @param conversationListBehaviorListener
     */
    public static void setConversationListBehaviorListener(ChatEventConversationListBehaviorListener conversationListBehaviorListener) {
        RongIM.getInstance().setConversationListBehaviorListener(conversationListBehaviorListener);
    }


    public static void releaseAll() {
        RongIM.getInstance().setConversationClickListener(null);
        RongIM.getInstance().setConversationListBehaviorListener(null);
    }
}
